/*todo:
 * выбрасывание вещей в препятствия
 * 
 * 
 * */
package com.pakazaka.simplecrawler;

import com.pakazaka.layer.ItemIcons;
import com.pakazaka.layer.tiles.Tile;
import com.pakazaka.controllers.Controller;
import com.pakazaka.player.Equip;
import static com.pakazaka.simplecrawler.Core.getInstance;

import javax.swing.*;
import java.io.IOException;
import static javax.imageio.ImageIO.read;

/**
 * @author Remi
 */
public class SimpleCrawler extends JFrame {

    public static final int windowWidth = 960, windowHeight = 432;
    public final static int mapw = 64, maph = 64;
    public static final int game_width = Tile.WIDTH * Constants.gameWidth, game_height = Tile.HEIGHT * Constants.gameHeight;
    public static ItemIcons resources, mobs, weapons, armor, drink, food;
    public static ItemIcons all;

    public SimpleCrawler() {
        setTitle("SimpleCrawler");
        setResizable(false);

        setBounds(100, 100, windowWidth, windowHeight);
        addKeyListener(new Controller());

        //создаём наборы тайлов для разных типов вещей
        try {
            resources = new ItemIcons(Tile.SIZE, read(getClass().getResourceAsStream("/res/objects.png")));
            mobs = new ItemIcons(Tile.SIZE, read(getClass().getResourceAsStream("/res/enemy.png")));
            all = new ItemIcons(Tile.SIZE, read(getClass().getResourceAsStream("/res/all.png")));
        } catch (IOException ex) {
            System.out.println("Cannot load icons.");
        }

        new PrototypeLoader().load("/res/json/containers.json");
        new PrototypeLoader().load("/res/json/instruments.json");
        new PrototypeLoader().load("/res/json/supply.json");
        new PrototypeLoader().load("/res/json/trash.json");
        new PrototypeLoader().load("/res/json/wear.json");
        

        getInstance().getPlayer().setEquip(new Equip());
        getInstance().getPlayer().setNick("Remi");

    }

    public static void main(String[] args) {
        SimpleCrawler sc = new SimpleCrawler();
        sc.add(getInstance());
        sc.setDefaultCloseOperation(EXIT_ON_CLOSE);
        sc.setVisible(true);
    }

}
